package test.SoundDriver;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;


import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.widget.TextView;

public class SoundDriver extends Activity implements SensorEventListener {
	/** Called when the activity is first created. */
	private TextView myTextView;
	private Shaker myShaker;	
	static final int SHAKE_THRESHOLD = 2;
	static final int SHAKE_GAP = 50;
	
	private class ShakeHandler implements Shaker.Callback {
		public void shakingStarted() {			
			myTextView = (TextView) findViewById(R.id.myTextView);
			String welcome_mes = "Shaking!!!!!!!!!!!";
			myTextView.setText(welcome_mes);
		}
		public void shakingStopped() {			
			myTextView = (TextView) findViewById(R.id.myTextView);
			String welcome_mes = "Quiet..........";
			myTextView.setText(welcome_mes);
		}
	};

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);		
		myShaker = new Shaker(this, SHAKE_THRESHOLD, SHAKE_GAP,
				new ShakeHandler());		
	}

	@Override
	public void onAccuracyChanged(Sensor arg0, int arg1) {
		myShaker.listener.onAccuracyChanged(arg0, arg1);
	}

	@Override
	public void onSensorChanged(SensorEvent event) {
		myShaker.listener.onSensorChanged(event);
	}
	
}
